from typing import List, Optional, Any
from pydantic.types import UUID4
from app.crud.base import CRUDBase
from app.models import BroadcastTask, BroadcastTarget
from app.schemas import BroadcastTaskCreate, BroadcastTaskUpdate, BroadcastTargetCreate, BroadcastTargetUpdate
from sqlalchemy.orm import Session

broadcast_task = CRUDBase[BroadcastTask, BroadcastTaskCreate, BroadcastTaskUpdate](BroadcastTask)


class CRUDBroadcastTarget(CRUDBase[BroadcastTarget, BroadcastTargetCreate, BroadcastTargetUpdate]):
    def get_multi_by_ids(
            self, db: Session, *, ids: List[UUID4], with_archived: Optional[bool] = False
    ) -> Any:
        query = db.query(BroadcastTarget).filter(BroadcastTarget.id.in_(ids))
        query = self.filter_archivable(query, with_archived)
        return query.all()


broadcast_target = CRUDBroadcastTarget(BroadcastTarget)
